package com.baidu.controller.listener;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
public class SessionLitener implements HttpSessionAttributeListener {
    @Override
    public void attributeAdded(HttpSessionBindingEvent se) {
        System.out.println("监听到了session域中数据的添加");
        HttpSession session = se.getSession();
        Object  username = session.getAttribute("username");
        System.out.println("监听"+username+"到用户登录");
        System.out.println("监听到"+username+"正在查询数据");
        Object  students = session.getAttribute("students");
    }
    @Override
    public void attributeReplaced(HttpSessionBindingEvent se) {
        System.out.println("监听到了session域中数据的修改");
        Object username = se.getSession().getAttribute("username");
        System.out.println("监听到"+username+"正在查询数据");
        Object students = se.getSession().getAttribute("students");
    }

}
